<?php
	/**
	 *	Wap Portal Server
	 *
	 *	Copyright (C) 2002 - 2004 Emir Sakic
	 *
	 *	Wap Portal Server
	 *	Developer: Emir Sakic - saka@hotmail.com
	 *  Homepage: http://www.sakic.net
	 *	Date: 15/03/2004
	 * 	Version #: 1.2
	**/

//error_reporting (E_ALL);

include ("../regglobals.php");
include ("../config.php");
include("../lang/".$language);

if (empty($option)) {
	$option = "";
}

if ($option=="logout") {
	$logout = true;
} else if (isset($option) && $option=="admins") {
	$minUserLevel = 2;
} else {
	$minUserLevel = 1;
}
include("secure.php");

// Establish connection with database and select database
$link = mysql_connect($db_host, $db_user, $db_password)
    or die("Could not connect");
mysql_select_db($db_name)
    or die("Could not select database");

include "includes/common.php";
$common = new common();
?>
<html>
<head>
<title>Wap Portal Server Administration Area</title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo _ENCODING_TAG; ?>">
<link rel="stylesheet" href="css/admin.css" type="text/css">
<script language="JavaScript1.2" src="javascript/javascript.js" type="text/javascript"></script>
<?php
$query = "SELECT javascript FROM wps_emulator WHERE id = 1";
$result = mysql_query($query);
$row = mysql_fetch_row ($result);
echo $row[0];
?>
</head>
<body>
<div align="center">
  <?php include('includes/header.php');?>
  <br>
<?php
switch($option) {
	case "admins" :
		require ("includes/admins.php");
		break;
	case "site" :
		require ("includes/site.php");
		break;
	case "time" :
		require ("includes/time.php");
		break;
	case "date" :
		require ("includes/date.php");
		break;
	case "emulator" :
		require ("includes/emulator.php");
		break;
	case "sections" :
		require ("includes/sections.php");
		break;
	case "items" :
		require ("includes/items.php");
		break;
	case "menu" :
		require ("includes/menu.php");
		break;
	case "links" :
		require ("includes/links.php");
		break;
	case "guestbook" :
		require ("includes/guestbook.php");
		break;
	case "contact" :
		require ("includes/contact.php");
		break;
	case "poll" :
		require ("includes/poll.php");
		break;
	case "logo" :
		require ("includes/logo.php");
		break;
	case "stats" :
		require ("includes/stats.php");
		break;
	case "about" :
		require ("includes/about.php");
		break;
	case "logout" :
		require ("includes/goodbye.php");
		break;
	default:
		require ("includes/home.php");
		break;
}
	include('includes/footer.php');
?>
</div>
</body>
</html>
<?php
/**
* Page navigation support functions
*
* Input:
* $limitstart (int The record number to start dislpaying from)
* $limit (int Number of rows to display per page)
* $total (int Total number of rows)
*/

/**
* Writes the html links for pages, eg, previous 1 2 3 ... x next
*/
	function writePagesLinks($limitstart, $limit, $total, $option) {
		$displayed_pages = 10;
		$total_pages = ceil( $total / $limit );
		$this_page = ceil( ($limitstart+1) / $limit );
		$start_loop = (floor(($this_page-1)/$displayed_pages))*$displayed_pages+1;
		if ($start_loop + $displayed_pages - 1 < $total_pages) {
			$stop_loop = $start_loop + $displayed_pages - 1;
		} else {
			$stop_loop = $total_pages;
		}

		if ($this_page > 1) {
			$page = ($this_page - 2) * $limit;
			echo "\n<a href=\"index.php?option=$option&limitstart=0\" title=\"first page\"><<</a>";
			echo "\n<a href=\"index.php?option=$option&limitstart=$page\" title=\"previous page\"><</a>";
		} else {
			echo "\n<<";
			echo "\n<";
		}

		for ($i=$start_loop; $i <= $stop_loop; $i++) {
			$page = ($i - 1) * $limit;
			if ($i == $this_page) {
				echo "\n $i ";
			} else {
				echo "\n<a href=\"index.php?option=$option&limitstart=$page\">$i</a>";
			}
		}

		if ($this_page < $total_pages) {
			$page = $this_page * $limit;
			$end_page = ($total_pages-1) * $limit;
			echo "\n<a href=\"index.php?option=$option&limitstart=$page\" title=\"next page\">></a>";
			echo "\n<a href=\"index.php?option=$option&limitstart=$end_page\" title=\"end page\">>></a>";
		} else {
			echo "\n>";
			echo "\n>>";
		}
	}

/**
* Writes the html for the pages counter, eg, Results 1-10 of x
*/
	function writePagesCounter($limitstart, $limit, $total) {
		$from_result = $limitstart+1;
		if ($limitstart + $limit < $total) {
			$to_result = $limitstart + $limit;
		} else {
			$to_result = $total;
		}
		if ($total > 0) {
			echo "\nResults " . $from_result . " - " . $to_result . " of " . $total;
		} else {
			echo "\nNo records found.";
		}
	}

/**
* Writes the UBB insert code
*/
	function insertUBBbuttons() {
?>
&nbsp;<input type="button" class="helpbutton" accesskey="b" name="addbbcode0" value=" B " style="font-weight:bold; width: 30px" onClick="bbstyle(0)" onMouseOver="helpline('b')" />&nbsp;
<input type="button" class="helpbutton" accesskey="i" name="addbbcode2" value=" i " style="font-style:italic; width: 30px" onClick="bbstyle(2)" onMouseOver="helpline('i')" />&nbsp;
<input type="button" class="helpbutton" accesskey="u" name="addbbcode4" value=" u " style="text-decoration: underline; width: 30px" onClick="bbstyle(4)" onMouseOver="helpline('u')" /><br>
<br>
&nbsp;<input type="button" class="helpbutton" accesskey="e" name="addbbcode10" value=" em " style="font-style:italic; width: 30px" onClick="bbstyle(10)" onMouseOver="helpline('e')" />&nbsp;
<input type="button" class="helpbutton" accesskey="t" name="addbbcode12" value=" S " style="font-weight:bold; width: 30px" onClick="bbstyle(12)" onMouseOver="helpline('t')" /><br>
<br>
&nbsp;<input type="button" class="helpbutton" accesskey="g" name="addbbcode6" value="Big" style="width: 40px" onClick="bbstyle(6)" onMouseOver="helpline('g')" />&nbsp;
<input type="button" class="helpbutton" accesskey="m" name="addbbcode8" value="Small" style="width: 40px" onClick="bbstyle(8)" onMouseOver="helpline('m')" /><br>
<br>
&nbsp;<input type="button" class="helpbutton" accesskey="p" name="addbbcode14" value="Img" style="width: 40px"  onClick="bbstyle(14)" onMouseOver="helpline('p')" />&nbsp;
<input type="button" class="helpbutton" accesskey="w" name="addbbcode16" value="URL" style="text-decoration: underline; width: 40px" onClick="bbstyle(16)" onMouseOver="helpline('w')" />
<?php
	}

	function insertUBBhelp() {
?>
<input type="text" name="helpbox" size="45" maxlength="100" style="width:450px; font-size:10px" class="helpline" value="Tip: Styles can be applied quickly to selected text" />
<?php
	}

?>